package com.hadwinling.blog.mapper;

import com.hadwinling.blog.entity.Article;
import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;import java.util.List;

/**
 * @author HadwinLing
 * @version V1.0
 * @Package com.hadwinling.blog.mapper
 * @date 2020/8/21 15:18
 */
@Mapper
public interface ArticleMapper {
    /**
     * delete by primary key
     *
     * @param id primaryKey
     * @return deleteCount
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * insert record to table
     *
     * @param record the record
     * @return insert count
     */
    int insert(Article record);

    /**
     * insert record to table selective
     *
     * @param record the record
     * @return insert count
     */
    int insertSelective(Article record);

    /**
     * select by primary key
     *
     * @param id primary key
     * @return object by primary key
     */
    Article selectByPrimaryKey(Integer id);

    /**
     * update record selective
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKeySelective(Article record);

    /**
     * update record
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKey(Article record);

    List<Article> selectAllByState(@Param("state") Integer state);

    Article selectAllByStateAndId(@Param("state") Integer state, @Param("id") Integer articleid);

    List<Article> selectAllSelective(Article article);

    List<Article> selectAllByAdminid(@Param("adminid") Integer adminid,Integer limitnum);

    int countByState(int state);

    List<Article> selectAllByStateAndTop(@Param("state") Integer state, @Param("top") Integer top);

    int updateTopById(@Param("updatedTop") Integer updatedTop, @Param("id") Integer id);

    List<Article> selectAllByStateAndTagid(@Param("state") Integer state, @Param("tagid") Integer tagid);

    List<Article> selectAllByStateAndTagidAndAdminId(@Param("state") Integer state, @Param("tagid") Integer tagid,@Param("adminid") Integer adminid);

    List<Article> selectAllByAdminidAndState(@Param("adminid") Integer adminid,@Param("state") Integer state);

    List<Article> selectAllByAdminIdAndTitleAndTag(Article article);

    List<Article> selectAllByStateAndTagidAndLimit(@Param("state") Integer state, @Param("tagid") Integer tagid,Integer limitnum);

    int countLikeById(@Param("adminid") Integer adminid);

    List<Article> selectAllByStateOrderByCreatetimeDesc(@Param("state")Integer state);


}